import json
#读取文件中的信息
def openFile(url):
    with open(url,"r",encoding="utf-8") as txt:
        txt=json.load(txt)
        return txt

#为用户编写UserInfo类，对Json数据中的每个对象进行封装
class UserInfo:
    name=''
    email=''
    qq=''
    password=''
    def __init__(self,name,email,qq,password):
        self.name=name
        self.email=email
        self.qq=qq
        self.password=password
    #输出用户基本信息
    def __str__(self):
        print("name={},email={},qq={},password={}".format(self.name,self.email,self.qq,self.password))


txt=openFile("json.txt")
user={}
for i in range(len(txt)):
    user[i]=UserInfo(txt[i]["name"],txt[i]["email"],txt[i]["qq"],txt[i]["password"])
    user[i].__str__()
